package cn.org.book.shop.app.controller;

import cn.org.book.shop.app.service.UserInfoService;
import cn.org.book.shop.common.core.domain.AjaxResult;
import cn.org.book.shop.message.UserInfoBean;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * ap用户注册服务
 * 微信授权登陆等信息
 *
 * @blame Android Team
 */
@RestController
@RequestMapping("/v1/app/userInfo")
public class ApUserLoginController {


    @Resource
    private UserInfoService userInfoService;

    @PostMapping
    public AjaxResult getUserInfo(@RequestBody UserInfoBean userInfoBean) {
        return AjaxResult.success(userInfoService.saveUserInfo(userInfoBean));
    }

    /**
     * 根据设备编号查询用户信息
     *
     * @param deviceId 设备编号
     * @return
     */
    @GetMapping("/{deviceId}")
    public AjaxResult getUserInfoByDeviceId(@PathVariable String deviceId) {
        //TODO: 完善兼容使用openID查询
        return AjaxResult.success(userInfoService.selectUserInfoByDeviceId(deviceId));
    }


}
